package com.sgb.kjwl.view.ui.adapter.enterprise;

import android.content.Context;
import android.view.View;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemReceiptBinding;
import com.swgk.core.base.model.entity.InvoicingInfoEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;

import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.ArrayList;

public class ReceiptAdpater extends BaseRecycleAdapter<InvoicingInfoEntity>{

    public ReceiptAdpater(Context context) {
        super(context, R.layout.item_receipt, new ArrayList<>());
    }

    @Override
    public void convert(ItemViewHolder holder, InvoicingInfoEntity invoicingInfoEntity) {
        if(holder.getmBinding() instanceof ItemReceiptBinding){
            ((ItemReceiptBinding)holder.getmBinding()).setVariable(BR.model,invoicingInfoEntity);

            ((ItemReceiptBinding) holder.getmBinding()).tvZankanR.setOnClickListener(view -> {
                datas.get(holder.getIndex_position()).show = !datas.get(holder.getIndex_position()).show;
                notifyDataSetChanged();
            });
            ((ItemReceiptBinding) holder.getmBinding()).imageArrowR.setOnClickListener(view -> {
                datas.get(holder.getIndex_position()).show = !datas.get(holder.getIndex_position()).show;
                notifyDataSetChanged();
            });

            ((ItemReceiptBinding) holder.getmBinding()).linRecepitBank.setVisibility(invoicingInfoEntity.show? View.VISIBLE:View.GONE);
            ((ItemReceiptBinding) holder.getmBinding()).linRecepitBanknum.setVisibility(invoicingInfoEntity.show? View.VISIBLE:View.GONE);
            ((ItemReceiptBinding) holder.getmBinding()).linRecepitCompanypath.setVisibility(invoicingInfoEntity.show? View.VISIBLE:View.GONE);
            ((ItemReceiptBinding) holder.getmBinding()).linRecepitCompanyphone.setVisibility(invoicingInfoEntity.show? View.VISIBLE:View.GONE);

        }
    }
}
